﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Configuration;

namespace TaskMessage.Job
{
    /// <summary>
    /// 消息任务配置
    /// </summary>
    public class TaskMessageJobConfig
    {
        #region 实体对象
        /// <summary>
        /// 实体对象
        /// </summary>
        private static TaskMessageJobConfig _Instance;
        /// <summary>
        /// 锁变量
        /// </summary>
        private static object _Locker = new object();
        /// <summary>
        /// 单例对象
        /// </summary>
        public static TaskMessageJobConfig Instance
        {
            get
            {
                if (_Instance == null)
                {
                    lock (_Locker)
                    {
                        if (_Instance == null)
                            _Instance = new TaskMessageJobConfig();
                    }
                }

                return _Instance;
            }
        }
        #endregion

        #region Settings
        protected NameValueCollection _Settings = null;
        /// <summary>
        /// 配置节
        /// </summary>
        public NameValueCollection Settings
        {
            get
            {
                if (_Settings == null)
                {
                    _Settings = (NameValueCollection)ConfigurationManager.GetSection("TaskMessageJobConfig");
                }

                return _Settings;
            }
        }
        #endregion

        /// <summary>
        /// 发送间隔 毫秒
        /// </summary>
        public string jobsleeptime
        {
            get
            {
                return this.Settings["jobsleeptime"];
            }
        }


        /// <summary>
        /// 读取及操作数据命名空间
        /// </summary>
        public string DBNamespace
        {
            get
            {
                return this.Settings["DBNamespace"];
            }
        }

        /// <summary>
        /// 读取及操作数据类名
        /// </summary>
        public string DBClassName
        {
            get
            {
                return this.Settings["DBClassName"];
            }
        }

        /// <summary>
        /// 数据连接
        /// </summary>
        public string DataMssqlConn
        {
            get
            {
                return this.Settings["DataMssqlConn"];
            }
        }
        

    }
}
